#pragma once
//#include "stdafx.h"
#include "SpaceNode.h"

namespace org
{
	namespace spark
	{

		
		namespace space
		{
			
			using org::spark::math::Vector;
			//using org::spark::math::Vector4d;
			using namespace org::spark::math;
			SpaceNode::SpaceNode(Space *space)
			{
						//		System.out.println("Creating space node");

				InitializeInstanceFields();
				this->space = space;

				position = new Vector();
						//		oldPosition = new Vector();
				newPosition = new Vector();
			}

			/*Vector *SpaceNode::getPosition()
			{
				return new Vector(position);
			}*/

			Space *SpaceNode::getSpace()
			{
				return space;
			}

			Vector *SpaceNode::getNewPosition()
			{
				// FIXME: should it be new Vector(newPosition)?
				return newPosition;
			}

			void SpaceNode::AssociateAgent(SpaceAgent *agent)
			{
				this->agent = agent;
			}

			void SpaceNode::setRandomPosition()
			{
						//		oldPosition.set(position);
						//		position.set(space.getRandomPosition());

						//		space.changeNodePosition(this, oldPosition, position);
				newPosition->set_Renamed(*space->getRandomPosition());
				space->changeNodePosition(this);
			}

			void SpaceNode::jump(Vector *v)
			{
						//		oldPosition.set(position);
						//		position.set(v);
						//		Observer.getSpace().changeNodePosition(this, oldPosition, position);
				newPosition->set_Renamed(*v);
				space->changeNodePosition(this);
			}

			void SpaceNode::move(Vector *dv)
			{
						//		oldPosition.set(position);
						//		position.add(dv);
						//		Observer.getSpace().changeNodePosition(this, oldPosition, position);
				newPosition->add(*dv);
				space->changeNodePosition(this);
			}

			double SpaceNode::getRelativeSize()
			{
				return 1.0;
			}
			/*
			void SpaceNode::setColor(Vector *color)
			{
				this->color->set(color);
			}

			void SpaceNode::setColor(Vector4d *color)
			{
				this->color->set(color);
			}

			Vector4d *SpaceNode::getColor()
			{
				// TODO: new Vector(color) but then it is impossible to
				// modify individual color components
				return color;
			}*/
			/*
			Vector *SpaceNode::getColor3()
			{
				return new Vector(color->x, color->y, color->z);
			}*/
			/*
			double SpaceNode::getAlpha()
			{
				return color->a;
			}

			void SpaceNode::setAlpha(double a)
			{
				color->a = a;
			}

			Vector *SpaceNode::getRGBColor()
			{
				return new Vector(color->x, color->y, color->z);
			}
			*/
			void SpaceNode::setRotation(double theta)
			{
				this->rotation = theta;
			}

			void SpaceNode::addRotation(double dtheta)
			{
				this->rotation += dtheta;
			}

			double SpaceNode::getRotation()
			{
				return rotation;
			}
			/*
			std::string SpaceNode::ToString()
			{
				std::string str = "";

				str += "Space: " + space + "; ";
// There is no native C++ equivalent to 'toString':
				str += "State: " + int::toString(state) + "; ";
// There is no native C++ equivalent to 'toString':
				str += "Position: " + position->toString() + "; ";
// There is no native C++ equivalent to 'toString':
				str += "NewPosition: " + newPosition->toString() + "; ";

				return str;
			}*/

			void SpaceNode::InitializeInstanceFields()
			{
				nodeIsRemoved = false;
				//color = new org::spark::math::Vector4d(0, 0, 0, 1);
			}
		}
	}
}
